#include <iostream>
#include <ctime>

using namespace std;

#define N 6

int max(int a[N][N]);

int main ( )
{
    int a[N][N],s,i,j;

    srand((unsigned int)time(0));

    for(i=0;i<N;i++)
        for(j=0;j<N;j++)
        {
            a[i][j]=rand()%100;
            cout<<a[i][j]<<"   ";
        }

    s=max(a);
    cout<<endl<<"the max value is"<<s<<endl;

    cin>>s;
    return 0;
}

int max(int a[N][N])
{
    int amax[N],s,i,j;

    for(i=0;i<N;i++)
    {
        s=a[i][0];

        for(j=1;j<N;j++)
            if(s<a[i][j]) s=a[i][j];

        amax[i]=s;
    }

    for(i=0;i<N;i++)
    {
        if(s<amax[i])
            s=amax[i];
    }

    return s;
}